package han.cirno.corrupt.activity.main

import androidx.navigation.NavController
import han.cirno.corrupt.Application
import han.cirno.corrupt.R
import han.cirno.corrupt.components.school.SchoolImpl
import han.cirno.corrupt.components.school.SchoolProvider

object FunctionSelector {
    private fun checkFunction(name:String):Boolean{
        val impl= SchoolImpl.impl?:return false
        return impl.hasInfo(name)
    }

    val functionTable= arrayOf(
        Function(
            R.string.functions_exams,
            R.drawable.baseline_school_24,
            { checkFunction(SchoolProvider.INFO_EXAMS) },
            {it.navigate(NavItem.ExamsFunction)}),
        Function(
            R.string.functions_scores,
            R.drawable.baseline_star_24,
            { checkFunction(SchoolProvider.INFO_SCORE) },
            {it.navigate(NavItem.ScoreFunction)}),
        Function(
            R.string.functions_nofy,
            R.drawable.baseline_brightness_5_24,
            {Application.application.globalViewModel.broadcastCheck.value==1},
            {it.navigate(NavItem.NofyFunction)}
        ),
        Function(
            R.string.functions_fafuLib,
            R.drawable.baseline_library_books_24,
            {true},
            {it.navigate(NavItem.LibraryFunction)}
        )
        )

    data class Function(
        val nameRes:Int,
        val iconRes:Int,
        val showPredicate:()->Boolean,
        val navJump:((NavController)->Unit)?=null
    )
}